import { ref } from 'vue'

export function useWorkExpPicker() {
	const pickerRef = ref<any>(null)
	const columns = ref([
		{ label: '无经验', value: 0 },
		...Array.from({ length: 10 }).map((_, index) => ({ label: `${index + 1}年`, value: index + 1 })),
	])
	const show = ref(false)

	const open = (value: number) => {
		let pickerIndex = 0

		if (value) {
			pickerIndex = columns.value.findIndex((item) => item.value === value)
		}

		pickerRef.value.setIndexs([pickerIndex])

		show.value = true
	}

	const close = () => {
		show.value = false
	}

	return {
		pickerRef,
		columns,
		show,
		open,
		close,
	}
}
